home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’95 / Venus / std.h < prev    next >
Encoding:
Text File  |  1995-06-23  |  4.0 KB  |  157 lines  |  [TEXT/EDIT]

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988, 1992 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #pragma once
  21. #ifndef _std_h
  22. #define _std_h 1
  23.  
  24. #include <stddef.h>
  25.  
  26. #if 0
  27. typedef unsigned size_t;
  28. #endif
  29.  
  30. typedef char wchar_t;
  31.  
  32. #ifndef NULL
  33. #ifdef __cplusplus
  34. #define NULL        0
  35. #else
  36. #define NULL        ((void *) 0)
  37. #endif
  38. #endif
  39.  
  40. inline int abs(const int x) { return x >= 0 ? x : -x; }
  41.  
  42. //------------------------------------------------------------------------
  43. //          The following is rolled-out <stdlib.h>
  44. //
  45.  
  46.  
  47. extern "C" {
  48.  
  49. typedef struct { int quot, rem; } div_t;
  50. typedef struct { long quot, rem; } ldiv_t;
  51.  
  52. int atoi(const char *);
  53. long atol(const char *);
  54. double strtod(const char *, char **);
  55. long strtol(const char *, char **, int);
  56. unsigned long strtoul(const char *, char **, int);
  57.  
  58. int rand(void);
  59. void srand(unsigned);
  60.  
  61. void *calloc(size_t, size_t);
  62. void free(void *);
  63. void *malloc(size_t);
  64. void *realloc(void *, size_t);
  65.  
  66. void abort(void);
  67. int atexit(void (*)(void));
  68. void exit(int);
  69. char *getenv(const char *);
  70. int system(const char *);
  71.  
  72. typedef int (*__cmp_func)(const void *, const void *);
  73. void *bsearch(const void *, const void *, size_t, size_t, __cmp_func);
  74. void qsort(void *, size_t, size_t, void *);
  75.  
  76. //int abs(int);
  77. div_t div(int, int);
  78. long labs(long);
  79. ldiv_t ldiv(long, long);
  80.  
  81. int mblen(const char *, size_t);
  82. int mbtowc(wchar_t *, const char *, size_t);
  83. int wctomb(char *, wchar_t);
  84.  
  85. size_t mbstowcs(wchar_t *, const char *, size_t);
  86. size_t wcstombs(char *, const wchar_t *, size_t);
  87.  
  88. typedef void (*__exit_func)(void);
  89. void _exit(int);
  90. int _atexit(__exit_func);
  91. void _exiting(int);
  92. extern int _abnormal_exit;
  93.  
  94. typedef int (*__cmp1_func)(size_t, size_t);
  95. typedef void (*__swap1_func)(size_t, size_t);
  96. void _qsort(size_t, __cmp1_func, __swap1_func);
  97.  
  98. }
  99.  
  100.  
  101. //------------------------------------------------------------------------
  102. //         The following is rolled-out <string.h>
  103. //
  104. extern "C" {
  105.  
  106. void *memcpy(void *, const void *, size_t);
  107. void *memmove(void *, const void *, size_t);
  108. char *strcpy(char *, const char *);
  109. char *strncpy(char *, const char *, size_t);
  110.  
  111. char *strcat(char *, const char *);
  112. char *strncat(char *, const char *, size_t);
  113.  
  114. int memcmp(const void *, const void *, size_t);
  115. int strcmp(const char *, const char *);
  116. int strcoll(const char *, const char *);
  117. int strncmp(const char *, const char *, size_t);
  118. size_t strxfrm(char *, const char *, size_t);
  119.  
  120. void *memchr(const void *, int, size_t);
  121. char *strchr(const char *, int);
  122. size_t strcspn(const char *, const char *);
  123. char *strpbrk(const char *, const char *);
  124. char *strrchr(const char *, int);
  125. size_t strspn(const char *, const char *);
  126. char *strstr(const char *, const char *);
  127. char *strtok(char *, const char *);
  128.  
  129. void *memset(void *, int, size_t);
  130. char *strerror(int);
  131. size_t strlen(const char *);
  132. int sprintf(char *, const char *, ...);
  133. int sscanf(const char *, const char *, ...);
  134. }
  135.  
  136. inline char * strdup(const char * str) { return strcpy((char *)malloc(strlen(str)+1),str); }
  137.  
  138.  
  139. //------------------------------------------------------------------------
  140. //        The following is rolled-out <memory.h>
  141. //
  142.  
  143.  
  144.  
  145. //------------------------------------------------------------------------
  146. //        The following is rolled-out <errno.h>
  147.  
  148. #include <errno.h>
  149.  
  150.  
  151. //#include <unistd.h>
  152. //#include <stdio.h> 
  153. //#include <fcntl.h>
  154.  
  155. #endif 
  156.  
  157.